using System.Reflection;
using Gridify;
using Gridify.WebAPI.Data;
using Gridify.WebAPI.Extensions;
using Microsoft.EntityFrameworkCore;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddControllers();
builder.Services.AddSwaggerGen();
//If you want to use gridify with Entity Framework, you should enable the compatibility layer
GridifyGlobalConfiguration.EnableEntityFrameworkCompatibilityLayer();

builder.Services.AddDbContext<ApplicationDbContext>(
    opt => opt.UseInMemoryDatabase("GridifySample"));
//register mapping profiles 
builder.Services.AddGridifyMappers(Assembly.GetExecutingAssembly());
builder.Services.AddAutoMapper(Assembly.GetExecutingAssembly());

var app = builder.Build();
if (app.Environment.IsDevelopment())
{
    app.UseSwaggerWithUi();
    app.MakeSureDbCreated();
}

app.UseHttpsRedirection();
app.MapControllers();
app.Run();

